{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data Mining, an introduction to the Pandas package \n",
    "This is a companion notebook for video content presented as part of the Data Mining course at SMU.\n",
    "\n",
    "In this tutorial we will be looking at a number of different parts of the Pandas package for data analysis, including:\n",
    "- Data Frames\n",
    " - loading data\n",
    " - head and tail commands\n",
    "- Munging\n",
    " - indexing operations\n",
    " - basic statistics\n",
    " - encoding\n",
    " - imputation (optional)\n",
    "- bonus: calling R with magics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data Frames\n",
    "Data frames in Pandas are basically like tables of data that you can do some really interesting relational database operations upon. There are many built in methods for aggregation and visualization, but we will cover those next time."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First lets load a typical table of data from a csv file. You can download the file from here:\n",
    "https://archive.ics.uci.edu/ml/datasets/Heart+Disease\n",
    "\n",
    "Make sure to place it in this directory or adjust the path for the file.\n",
    "### Reading Data from CSV with Pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "site,age,is_male,chest_pain,rest_blood_press,cholesterol,high_blood_sugar,rest_ecg,max_heart_rate,exer_angina,ST_depression,Peak_ST_seg,major_vessels,thal,has_heart_disease\n",
      " cleve,63,1,1,145,233,1,2,150,0,2.3,3,0,6,0\n",
      " cleve,67,1,4,160,286,0,2,108,1,1.5,2,3,3,2\n",
      " cleve,67,1,4,120,229,0,2,129,1,2.6,2,2,7,1\n",
      " cleve,37,1,3,130,250,0,0,187,0,3.5,3,0,3,0\n",
      " "
     ]
    }
   ],
   "source": [
    "# let's print out the first five rows inside a csv file\n",
    "\n",
    "# NOTE: you may need to change the path to the file, \n",
    "#       depending on where you saved the data\n",
    "with open('data/heart_disease.csv') as fid:\n",
    "    for idx, row in enumerate(fid):\n",
    "        print (row,end=' ')\n",
    "        if idx >= 4:\n",
    "            break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# now let's read in the same data using pandas to save it as a dataframe\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv('data/heart_disease.csv') # read in the csv file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>site</th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>cleve</td>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>145</td>\n",
       "      <td>233</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>150</td>\n",
       "      <td>0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>cleve</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>160</td>\n",
       "      <td>286</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>108</td>\n",
       "      <td>1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>cleve</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>120</td>\n",
       "      <td>229</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>129</td>\n",
       "      <td>1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>cleve</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>130</td>\n",
       "      <td>250</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>187</td>\n",
       "      <td>0</td>\n",
       "      <td>3.5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>cleve</td>\n",
       "      <td>41</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>130</td>\n",
       "      <td>204</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>172</td>\n",
       "      <td>0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    site  age  is_male  chest_pain rest_blood_press cholesterol  \\\n",
       "0  cleve   63        1           1              145         233   \n",
       "1  cleve   67        1           4              160         286   \n",
       "2  cleve   67        1           4              120         229   \n",
       "3  cleve   37        1           3              130         250   \n",
       "4  cleve   41        0           2              130         204   \n",
       "\n",
       "  high_blood_sugar rest_ecg max_heart_rate exer_angina ST_depression  \\\n",
       "0                1        2            150           0           2.3   \n",
       "1                0        2            108           1           1.5   \n",
       "2                0        2            129           1           2.6   \n",
       "3                0        0            187           0           3.5   \n",
       "4                0        2            172           0           1.4   \n",
       "\n",
       "  Peak_ST_seg major_vessels thal  has_heart_disease  \n",
       "0           3             0    6                  0  \n",
       "1           2             3    3                  2  \n",
       "2           2             2    7                  1  \n",
       "3           3             0    3                  0  \n",
       "4           1             0    3                  0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# now lets look at the data\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 15 columns):\n",
      "site                 920 non-null object\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null int64\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: int64(4), object(11)\n",
      "memory usage: 107.9+ KB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "# now let's a get a summary of the variables \n",
    "print (df.info())\n",
    "# we can see that most of the data \n",
    "#  is saved as an integer or as a nominal object"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This data has been read into working memory and is known as a DataFrame.\n",
    "\n",
    "### Reading Data from SQLite3 with Pandas\n",
    "We can also connect to a sqlite3 database using the built in sqlite3 package that ships with python. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>site</th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>cleve</td>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>145</td>\n",
       "      <td>233</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>150</td>\n",
       "      <td>0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>cleve</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>160</td>\n",
       "      <td>286</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>108</td>\n",
       "      <td>1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>cleve</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>120</td>\n",
       "      <td>229</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>129</td>\n",
       "      <td>1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>cleve</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>130</td>\n",
       "      <td>250</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>187</td>\n",
       "      <td>0</td>\n",
       "      <td>3.5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>cleve</td>\n",
       "      <td>41</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>130</td>\n",
       "      <td>204</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>172</td>\n",
       "      <td>0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    site age is_male chest_pain rest_blood_press cholesterol high_blood_sugar  \\\n",
       "0  cleve  63       1          1              145         233                1   \n",
       "1  cleve  67       1          4              160         286                0   \n",
       "2  cleve  67       1          4              120         229                0   \n",
       "3  cleve  37       1          3              130         250                0   \n",
       "4  cleve  41       0          2              130         204                0   \n",
       "\n",
       "  rest_ecg max_heart_rate exer_angina ST_depression Peak_ST_seg major_vessels  \\\n",
       "0        2            150           0           2.3           3             0   \n",
       "1        2            108           1           1.5           2             3   \n",
       "2        2            129           1           2.6           2             2   \n",
       "3        0            187           0           3.5           3             0   \n",
       "4        2            172           0           1.4           1             0   \n",
       "\n",
       "  thal has_heart_disease  \n",
       "0    6                 0  \n",
       "1    3                 2  \n",
       "2    7                 1  \n",
       "3    3                 0  \n",
       "4    3                 0  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# but csv files are not the only thing we can work with\n",
    "# what if the data was actually in a sqlite database?\n",
    "del df\n",
    "import sqlite3\n",
    "\n",
    "con = sqlite3.connect('data/heart_disease_sql') # again this file is in the same directory\n",
    "df = pd.read_sql('SELECT * FROM heart_disease', con)  # the table name is heart_disease\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 15 columns):\n",
      "site                 920 non-null object\n",
      "age                  920 non-null object\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null object\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null object\n",
      "dtypes: object(15)\n",
      "memory usage: 107.9+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()\n",
    "# notice now, however, that the data types are all objects!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ### Working with DataFrames\n",
    " We can index in to DataFrame in a number of ways:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0      63\n",
      "1      67\n",
      "2      67\n",
      "3      37\n",
      "4      41\n",
      "5      56\n",
      "6      62\n",
      "7      57\n",
      "8      63\n",
      "9      53\n",
      "10     57\n",
      "11     56\n",
      "12     56\n",
      "13     44\n",
      "14     52\n",
      "15     57\n",
      "16     48\n",
      "17     54\n",
      "18     48\n",
      "19     49\n",
      "20     64\n",
      "21     58\n",
      "22     58\n",
      "23     58\n",
      "24     60\n",
      "25     50\n",
      "26     58\n",
      "27     66\n",
      "28     43\n",
      "29     40\n",
      "       ..\n",
      "890    52\n",
      "891    53\n",
      "892    53\n",
      "893    54\n",
      "894    55\n",
      "895    55\n",
      "896    55\n",
      "897    56\n",
      "898    56\n",
      "899    56\n",
      "900    58\n",
      "901    59\n",
      "902    59\n",
      "903    65\n",
      "904    66\n",
      "905    41\n",
      "906    43\n",
      "907    44\n",
      "908    47\n",
      "909    47\n",
      "910    49\n",
      "911    49\n",
      "912    50\n",
      "913    50\n",
      "914    52\n",
      "915    52\n",
      "916    54\n",
      "917    56\n",
      "918    58\n",
      "919    65\n",
      "Name: age, dtype: object\n",
      "0      63\n",
      "1      67\n",
      "2      67\n",
      "3      37\n",
      "4      41\n",
      "5      56\n",
      "6      62\n",
      "7      57\n",
      "8      63\n",
      "9      53\n",
      "10     57\n",
      "11     56\n",
      "12     56\n",
      "13     44\n",
      "14     52\n",
      "15     57\n",
      "16     48\n",
      "17     54\n",
      "18     48\n",
      "19     49\n",
      "20     64\n",
      "21     58\n",
      "22     58\n",
      "23     58\n",
      "24     60\n",
      "25     50\n",
      "26     58\n",
      "27     66\n",
      "28     43\n",
      "29     40\n",
      "       ..\n",
      "890    52\n",
      "891    53\n",
      "892    53\n",
      "893    54\n",
      "894    55\n",
      "895    55\n",
      "896    55\n",
      "897    56\n",
      "898    56\n",
      "899    56\n",
      "900    58\n",
      "901    59\n",
      "902    59\n",
      "903    65\n",
      "904    66\n",
      "905    41\n",
      "906    43\n",
      "907    44\n",
      "908    47\n",
      "909    47\n",
      "910    49\n",
      "911    49\n",
      "912    50\n",
      "913    50\n",
      "914    52\n",
      "915    52\n",
      "916    54\n",
      "917    56\n",
      "918    58\n",
      "919    65\n",
      "Name: age, dtype: object\n"
     ]
    }
   ],
   "source": [
    "# the variable names are embedded into the structure\n",
    "print (df.age)\n",
    "print (df['age']) # but can also be accessed using strings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 4 inf\n"
     ]
    }
   ],
   "source": [
    "print (df.chest_pain.min(), df.chest_pain.max(), df.chest_pain.mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null object\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null object\n",
      "rest_blood_press     920 non-null object\n",
      "cholesterol          920 non-null object\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null object\n",
      "max_heart_rate       920 non-null object\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null object\n",
      "Peak_ST_seg          920 non-null object\n",
      "major_vessels        920 non-null object\n",
      "thal                 920 non-null object\n",
      "has_heart_disease    920 non-null object\n",
      "dtypes: object(14)\n",
      "memory usage: 100.7+ KB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "# lets get rid of the 'site' variable\n",
    "if 'site' in df:\n",
    "    del df['site']\n",
    "\n",
    "print( df.info())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null int64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null int64\n",
      "major_vessels        920 non-null int64\n",
      "thal                 920 non-null int64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(4), int64(7), object(3)\n",
      "memory usage: 100.7+ KB\n"
     ]
    }
   ],
   "source": [
    "# Notice that all of the data is stored as a non-null object\n",
    "# That's not good. It means we need to change those data types\n",
    "# in order to encode the variables properly. Right now Pandas\n",
    "# thinks all of our variables are nominal!\n",
    "\n",
    "import numpy as np\n",
    "# replace '?' with -1, we will deal with missing values later\n",
    "df = df.replace(to_replace='?',value=-1) \n",
    "\n",
    "# let's start by first changing the numeric values to be floats\n",
    "continuous_features = ['rest_blood_press', 'cholesterol', \n",
    "                       'max_heart_rate', 'ST_depression']\n",
    "\n",
    "# and the oridnal values to be integers\n",
    "ordinal_features = ['age','major_vessels','chest_pain',\n",
    "                    'rest_ecg','Peak_ST_seg','thal','has_heart_disease']\n",
    "\n",
    "# we won't touch these variables, keep them as categorical\n",
    "categ_features = ['is_male','high_blood_sugar','exer_angina'];\n",
    "\n",
    "# use the \"astype\" function to change the variable type\n",
    "df[continuous_features] = df[continuous_features].astype(np.float64)\n",
    "df[ordinal_features] = df[ordinal_features].astype(np.int64)\n",
    "\n",
    "df.info() # now our data looks better!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>is_male</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>exer_angina</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>145.0</td>\n",
       "      <td>233.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>150.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>160.0</td>\n",
       "      <td>286.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>108.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>120.0</td>\n",
       "      <td>229.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>129.0</td>\n",
       "      <td>1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>130.0</td>\n",
       "      <td>250.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>187.0</td>\n",
       "      <td>0</td>\n",
       "      <td>3.5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>41</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>130.0</td>\n",
       "      <td>204.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>172.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age is_male  chest_pain  rest_blood_press  cholesterol high_blood_sugar  \\\n",
       "0   63       1           1             145.0        233.0                1   \n",
       "1   67       1           4             160.0        286.0                0   \n",
       "2   67       1           4             120.0        229.0                0   \n",
       "3   37       1           3             130.0        250.0                0   \n",
       "4   41       0           2             130.0        204.0                0   \n",
       "\n",
       "   rest_ecg  max_heart_rate exer_angina  ST_depression  Peak_ST_seg  \\\n",
       "0         2           150.0           0            2.3            3   \n",
       "1         2           108.0           1            1.5            2   \n",
       "2         2           129.0           1            2.6            2   \n",
       "3         0           187.0           0            3.5            3   \n",
       "4         2           172.0           0            1.4            1   \n",
       "\n",
       "   major_vessels  thal  has_heart_disease  \n",
       "0              0     6                  0  \n",
       "1              3     3                  2  \n",
       "2              2     7                  1  \n",
       "3              0     3                  0  \n",
       "4              0     3                  0  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's get summary of all attributes in the frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>53.510870</td>\n",
       "      <td>3.250000</td>\n",
       "      <td>123.594565</td>\n",
       "      <td>192.604348</td>\n",
       "      <td>0.601087</td>\n",
       "      <td>129.263043</td>\n",
       "      <td>0.752174</td>\n",
       "      <td>0.840217</td>\n",
       "      <td>-0.436957</td>\n",
       "      <td>1.871739</td>\n",
       "      <td>0.995652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.424685</td>\n",
       "      <td>0.930969</td>\n",
       "      <td>37.484705</td>\n",
       "      <td>114.615011</td>\n",
       "      <td>0.808415</td>\n",
       "      <td>41.376773</td>\n",
       "      <td>1.154353</td>\n",
       "      <td>1.403211</td>\n",
       "      <td>0.959656</td>\n",
       "      <td>3.313649</td>\n",
       "      <td>1.142693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>28.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-2.600000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>47.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>120.000000</td>\n",
       "      <td>164.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>115.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>54.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>130.000000</td>\n",
       "      <td>221.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>138.000000</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>60.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>140.000000</td>\n",
       "      <td>267.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>156.000000</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>77.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>200.000000</td>\n",
       "      <td>603.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>202.000000</td>\n",
       "      <td>6.200000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  920.000000  920.000000        920.000000   920.000000  920.000000   \n",
       "mean    53.510870    3.250000        123.594565   192.604348    0.601087   \n",
       "std      9.424685    0.930969         37.484705   114.615011    0.808415   \n",
       "min     28.000000    1.000000         -1.000000    -1.000000   -1.000000   \n",
       "25%     47.000000    3.000000        120.000000   164.000000    0.000000   \n",
       "50%     54.000000    4.000000        130.000000   221.000000    0.000000   \n",
       "75%     60.000000    4.000000        140.000000   267.000000    1.000000   \n",
       "max     77.000000    4.000000        200.000000   603.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      920.000000     920.000000   920.000000     920.000000  920.000000   \n",
       "mean       129.263043       0.752174     0.840217      -0.436957    1.871739   \n",
       "std         41.376773       1.154353     1.403211       0.959656    3.313649   \n",
       "min         -1.000000      -2.600000    -1.000000      -1.000000   -1.000000   \n",
       "25%        115.000000       0.000000    -1.000000      -1.000000   -1.000000   \n",
       "50%        138.000000       0.200000     1.000000      -1.000000   -1.000000   \n",
       "75%        156.000000       1.500000     2.000000       0.000000    6.000000   \n",
       "max        202.000000       6.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count         920.000000  \n",
       "mean            0.995652  \n",
       "std             1.142693  \n",
       "min             0.000000  \n",
       "25%             0.000000  \n",
       "50%             1.000000  \n",
       "75%             2.000000  \n",
       "max             4.000000  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe() # will get summary of continuous or the nominals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 920 entries in this data frame. Notice that this data frame has a number of missing values denoted by the value -1 (that we changed the '?' value to before). We need to either remove the missing values from the dataset OR we need to fill in with our best guess for those values. Let's first drop all the rows with missing values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     861 non-null float64\n",
      "cholesterol          890 non-null float64\n",
      "high_blood_sugar     830 non-null object\n",
      "rest_ecg             918 non-null float64\n",
      "max_heart_rate       865 non-null float64\n",
      "exer_angina          865 non-null object\n",
      "ST_depression        856 non-null float64\n",
      "Peak_ST_seg          611 non-null float64\n",
      "major_vessels        309 non-null float64\n",
      "thal                 434 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)\n",
      "memory usage: 100.7+ KB\n",
      "None\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>920.000000</td>\n",
       "      <td>920.000000</td>\n",
       "      <td>861.000000</td>\n",
       "      <td>890.000000</td>\n",
       "      <td>918.000000</td>\n",
       "      <td>865.000000</td>\n",
       "      <td>856.000000</td>\n",
       "      <td>611.000000</td>\n",
       "      <td>309.000000</td>\n",
       "      <td>434.000000</td>\n",
       "      <td>920.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>53.510870</td>\n",
       "      <td>3.250000</td>\n",
       "      <td>132.132404</td>\n",
       "      <td>199.130337</td>\n",
       "      <td>0.604575</td>\n",
       "      <td>137.545665</td>\n",
       "      <td>0.883178</td>\n",
       "      <td>1.770867</td>\n",
       "      <td>0.676375</td>\n",
       "      <td>5.087558</td>\n",
       "      <td>0.995652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.424685</td>\n",
       "      <td>0.930969</td>\n",
       "      <td>19.066070</td>\n",
       "      <td>110.780810</td>\n",
       "      <td>0.805827</td>\n",
       "      <td>25.926276</td>\n",
       "      <td>1.088707</td>\n",
       "      <td>0.619256</td>\n",
       "      <td>0.935653</td>\n",
       "      <td>1.919075</td>\n",
       "      <td>1.142693</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>28.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>60.000000</td>\n",
       "      <td>-2.600000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>47.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>120.000000</td>\n",
       "      <td>175.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>120.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>54.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>130.000000</td>\n",
       "      <td>223.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>140.000000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>60.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>140.000000</td>\n",
       "      <td>268.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>157.000000</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>77.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>200.000000</td>\n",
       "      <td>603.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>202.000000</td>\n",
       "      <td>6.200000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  920.000000  920.000000        861.000000   890.000000  918.000000   \n",
       "mean    53.510870    3.250000        132.132404   199.130337    0.604575   \n",
       "std      9.424685    0.930969         19.066070   110.780810    0.805827   \n",
       "min     28.000000    1.000000          0.000000     0.000000    0.000000   \n",
       "25%     47.000000    3.000000        120.000000   175.000000    0.000000   \n",
       "50%     54.000000    4.000000        130.000000   223.000000    0.000000   \n",
       "75%     60.000000    4.000000        140.000000   268.000000    1.000000   \n",
       "max     77.000000    4.000000        200.000000   603.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      865.000000     856.000000   611.000000     309.000000  434.000000   \n",
       "mean       137.545665       0.883178     1.770867       0.676375    5.087558   \n",
       "std         25.926276       1.088707     0.619256       0.935653    1.919075   \n",
       "min         60.000000      -2.600000     1.000000       0.000000    3.000000   \n",
       "25%        120.000000       0.000000     1.000000       0.000000    3.000000   \n",
       "50%        140.000000       0.500000     2.000000       0.000000    6.000000   \n",
       "75%        157.000000       1.500000     2.000000       1.000000    7.000000   \n",
       "max        202.000000       6.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count         920.000000  \n",
       "mean            0.995652  \n",
       "std             1.142693  \n",
       "min             0.000000  \n",
       "25%             0.000000  \n",
       "50%             1.000000  \n",
       "75%             2.000000  \n",
       "max             4.000000  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# how many value have the -1 (which we set as the missing values) \n",
    "import numpy as np\n",
    "\n",
    "# let's set those values to NaN, so that Pandas understand they are missing\n",
    "df = df.replace(to_replace=-1,value=np.nan) # replace -1 with NaN (not a number)\n",
    "print (df.info())\n",
    "df.describe() # scroll over to see the values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Wow. Notice how the number of attributes went down in the description function. Looks like we need to impute values. If we drop the rows with missing data, we will be throwing away almost 80% of the data collected. No way!!\n",
    "\n",
    "### Imputation of NaN values (Optional)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "age                   54.0\n",
       "is_male                1.0\n",
       "chest_pain             4.0\n",
       "rest_blood_press     130.0\n",
       "cholesterol          223.0\n",
       "high_blood_sugar       0.0\n",
       "rest_ecg               0.0\n",
       "max_heart_rate       140.0\n",
       "exer_angina            0.0\n",
       "ST_depression          0.5\n",
       "Peak_ST_seg            2.0\n",
       "major_vessels          0.0\n",
       "thal                   6.0\n",
       "has_heart_disease      1.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# lets look at some stats of the data\n",
    "df.median() # only calculates for numeric data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null float64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null float64\n",
      "major_vessels        920 non-null float64\n",
      "thal                 920 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)\n",
      "memory usage: 100.7+ KB\n"
     ]
    }
   ],
   "source": [
    "# the 'fillna' function will take the given series (the output above)\n",
    "# and fill in the missing values for the columns it has\n",
    "df_imputed = df.fillna(df.median()) # note that to do this all values must be numeric\n",
    "df_imputed.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that the object variables are unchanged, but all the numeric/ordinal values have been filled in with the median of the columns. Let's try something (slightly) smarter, and fill in the oridinals with the median and the continuous with the mean."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "is_male                1.000000\n",
      "high_blood_sugar       0.000000\n",
      "exer_angina            0.000000\n",
      "age                   54.000000\n",
      "major_vessels          0.000000\n",
      "chest_pain             4.000000\n",
      "rest_ecg               0.000000\n",
      "Peak_ST_seg            2.000000\n",
      "thal                   6.000000\n",
      "has_heart_disease      1.000000\n",
      "rest_blood_press     132.132404\n",
      "cholesterol          199.130337\n",
      "max_heart_rate       137.545665\n",
      "ST_depression          0.883178\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "# make  one series for imputing with\n",
    "series_mean = df[continuous_features].mean()\n",
    "series_median = df[categ_features+ordinal_features].median()\n",
    "cat_series = pd.concat((series_median,series_mean))\n",
    "\n",
    "print (cat_series)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 920 entries, 0 to 919\n",
      "Data columns (total 14 columns):\n",
      "age                  920 non-null int64\n",
      "is_male              920 non-null object\n",
      "chest_pain           920 non-null int64\n",
      "rest_blood_press     920 non-null float64\n",
      "cholesterol          920 non-null float64\n",
      "high_blood_sugar     920 non-null object\n",
      "rest_ecg             920 non-null float64\n",
      "max_heart_rate       920 non-null float64\n",
      "exer_angina          920 non-null object\n",
      "ST_depression        920 non-null float64\n",
      "Peak_ST_seg          920 non-null float64\n",
      "major_vessels        920 non-null float64\n",
      "thal                 920 non-null float64\n",
      "has_heart_disease    920 non-null int64\n",
      "dtypes: float64(8), int64(3), object(3)\n",
      "memory usage: 100.7+ KB\n"
     ]
    }
   ],
   "source": [
    "# now let's impute the numbers a bit differently\n",
    "\n",
    "df_imputed = df.fillna(value=cat_series)\n",
    "df_imputed.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>is_male</th>\n",
       "      <th>high_blood_sugar</th>\n",
       "      <th>exer_angina</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>920</td>\n",
       "      <td>920</td>\n",
       "      <td>920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>unique</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>top</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>freq</th>\n",
       "      <td>726</td>\n",
       "      <td>692</td>\n",
       "      <td>528</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       is_male high_blood_sugar exer_angina\n",
       "count      920              920         920\n",
       "unique       2                3           3\n",
       "top          1                0           0\n",
       "freq       726              692         528"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_imputed[categ_features].describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Indexing logically into Data Frames\n",
    "Let's now say that we are only interested in the summary of the dataframe when the patient has heart disease. We can achieve this using a few line of code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>411.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>50.547445</td>\n",
       "      <td>2.761557</td>\n",
       "      <td>130.021042</td>\n",
       "      <td>226.575368</td>\n",
       "      <td>0.547445</td>\n",
       "      <td>148.252830</td>\n",
       "      <td>0.441963</td>\n",
       "      <td>1.729927</td>\n",
       "      <td>0.111922</td>\n",
       "      <td>5.085158</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>9.433700</td>\n",
       "      <td>0.903425</td>\n",
       "      <td>16.460208</td>\n",
       "      <td>74.301504</td>\n",
       "      <td>0.805204</td>\n",
       "      <td>23.152969</td>\n",
       "      <td>0.704565</td>\n",
       "      <td>0.515662</td>\n",
       "      <td>0.427276</td>\n",
       "      <td>1.510951</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>28.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>80.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>69.000000</td>\n",
       "      <td>-1.100000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>43.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>120.000000</td>\n",
       "      <td>199.130337</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>135.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>51.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>130.000000</td>\n",
       "      <td>225.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>150.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>57.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>140.000000</td>\n",
       "      <td>266.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>165.000000</td>\n",
       "      <td>0.883178</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>76.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>190.000000</td>\n",
       "      <td>564.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>202.000000</td>\n",
       "      <td>4.200000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              age  chest_pain  rest_blood_press  cholesterol    rest_ecg  \\\n",
       "count  411.000000  411.000000        411.000000   411.000000  411.000000   \n",
       "mean    50.547445    2.761557        130.021042   226.575368    0.547445   \n",
       "std      9.433700    0.903425         16.460208    74.301504    0.805204   \n",
       "min     28.000000    1.000000         80.000000     0.000000    0.000000   \n",
       "25%     43.000000    2.000000        120.000000   199.130337    0.000000   \n",
       "50%     51.000000    3.000000        130.000000   225.000000    0.000000   \n",
       "75%     57.000000    4.000000        140.000000   266.000000    1.000000   \n",
       "max     76.000000    4.000000        190.000000   564.000000    2.000000   \n",
       "\n",
       "       max_heart_rate  ST_depression  Peak_ST_seg  major_vessels        thal  \\\n",
       "count      411.000000     411.000000   411.000000     411.000000  411.000000   \n",
       "mean       148.252830       0.441963     1.729927       0.111922    5.085158   \n",
       "std         23.152969       0.704565     0.515662       0.427276    1.510951   \n",
       "min         69.000000      -1.100000     1.000000       0.000000    3.000000   \n",
       "25%        135.500000       0.000000     1.000000       0.000000    3.000000   \n",
       "50%        150.000000       0.000000     2.000000       0.000000    6.000000   \n",
       "75%        165.000000       0.883178     2.000000       0.000000    6.000000   \n",
       "max        202.000000       4.200000     3.000000       3.000000    7.000000   \n",
       "\n",
       "       has_heart_disease  \n",
       "count              411.0  \n",
       "mean                 0.0  \n",
       "std                  0.0  \n",
       "min                  0.0  \n",
       "25%                  0.0  \n",
       "50%                  0.0  \n",
       "75%                  0.0  \n",
       "max                  0.0  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_imputed[df_imputed.has_heart_disease==0].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>has_heart_disease</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>51</td>\n",
       "      <td>3</td>\n",
       "      <td>130.000000</td>\n",
       "      <td>225.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>150.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>55</td>\n",
       "      <td>4</td>\n",
       "      <td>130.000000</td>\n",
       "      <td>226.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>130.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>58</td>\n",
       "      <td>4</td>\n",
       "      <td>132.132404</td>\n",
       "      <td>193.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>130.0</td>\n",
       "      <td>1.40</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>60</td>\n",
       "      <td>4</td>\n",
       "      <td>132.132404</td>\n",
       "      <td>212.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>122.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>59</td>\n",
       "      <td>4</td>\n",
       "      <td>133.066202</td>\n",
       "      <td>218.5</td>\n",
       "      <td>1.0</td>\n",
       "      <td>126.5</td>\n",
       "      <td>2.45</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   age  chest_pain  rest_blood_press  cholesterol  rest_ecg  \\\n",
       "has_heart_disease                                                             \n",
       "0                   51           3        130.000000        225.0       0.0   \n",
       "1                   55           4        130.000000        226.0       0.0   \n",
       "2                   58           4        132.132404        193.0       0.0   \n",
       "3                   60           4        132.132404        212.0       1.0   \n",
       "4                   59           4        133.066202        218.5       1.0   \n",
       "\n",
       "                   max_heart_rate  ST_depression  Peak_ST_seg  major_vessels  \\\n",
       "has_heart_disease                                                              \n",
       "0                           150.0           0.00          2.0            0.0   \n",
       "1                           130.0           1.00          2.0            0.0   \n",
       "2                           130.0           1.40          2.0            0.0   \n",
       "3                           122.0           1.00          2.0            0.0   \n",
       "4                           126.5           2.45          2.0            0.0   \n",
       "\n",
       "                   thal  \n",
       "has_heart_disease        \n",
       "0                   6.0  \n",
       "1                   6.0  \n",
       "2                   6.0  \n",
       "3                   6.0  \n",
       "4                   6.0  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# or we can use the extremely useful \"groupby\" function\n",
    "df_imputed.groupby(by='has_heart_disease').median()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>has_heart_disease</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>False</th>\n",
       "      <td>50.547445</td>\n",
       "      <td>2.761557</td>\n",
       "      <td>130.021042</td>\n",
       "      <td>226.575368</td>\n",
       "      <td>0.547445</td>\n",
       "      <td>148.252830</td>\n",
       "      <td>0.441963</td>\n",
       "      <td>1.729927</td>\n",
       "      <td>0.111922</td>\n",
       "      <td>5.085158</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>True</th>\n",
       "      <td>55.903733</td>\n",
       "      <td>3.644401</td>\n",
       "      <td>133.837257</td>\n",
       "      <td>176.969418</td>\n",
       "      <td>0.648330</td>\n",
       "      <td>128.899997</td>\n",
       "      <td>1.239443</td>\n",
       "      <td>1.943026</td>\n",
       "      <td>0.320236</td>\n",
       "      <td>5.960707</td>\n",
       "      <td>1.799607</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         age  chest_pain  rest_blood_press  cholesterol  \\\n",
       "has_heart_disease                                                         \n",
       "False              50.547445    2.761557        130.021042   226.575368   \n",
       "True               55.903733    3.644401        133.837257   176.969418   \n",
       "\n",
       "                   rest_ecg  max_heart_rate  ST_depression  Peak_ST_seg  \\\n",
       "has_heart_disease                                                         \n",
       "False              0.547445      148.252830       0.441963     1.729927   \n",
       "True               0.648330      128.899997       1.239443     1.943026   \n",
       "\n",
       "                   major_vessels      thal  has_heart_disease  \n",
       "has_heart_disease                                              \n",
       "False                   0.111922  5.085158           0.000000  \n",
       "True                    0.320236  5.960707           1.799607  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_imputed.groupby(by=df_imputed.has_heart_disease>0).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>chest_pain</th>\n",
       "      <th>rest_blood_press</th>\n",
       "      <th>cholesterol</th>\n",
       "      <th>rest_ecg</th>\n",
       "      <th>max_heart_rate</th>\n",
       "      <th>ST_depression</th>\n",
       "      <th>Peak_ST_seg</th>\n",
       "      <th>major_vessels</th>\n",
       "      <th>thal</th>\n",
       "      <th>has_heart_disease</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>major_vessels</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>False</th>\n",
       "      <td>53.368889</td>\n",
       "      <td>3.241111</td>\n",
       "      <td>132.026458</td>\n",
       "      <td>197.656567</td>\n",
       "      <td>0.586667</td>\n",
       "      <td>137.612235</td>\n",
       "      <td>0.861359</td>\n",
       "      <td>1.847778</td>\n",
       "      <td>0.165556</td>\n",
       "      <td>5.566667</td>\n",
       "      <td>0.966667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>True</th>\n",
       "      <td>59.900000</td>\n",
       "      <td>3.650000</td>\n",
       "      <td>136.900000</td>\n",
       "      <td>265.450000</td>\n",
       "      <td>1.350000</td>\n",
       "      <td>134.550000</td>\n",
       "      <td>1.865000</td>\n",
       "      <td>1.850000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>5.700000</td>\n",
       "      <td>2.300000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     age  chest_pain  rest_blood_press  cholesterol  rest_ecg  \\\n",
       "major_vessels                                                                   \n",
       "False          53.368889    3.241111        132.026458   197.656567  0.586667   \n",
       "True           59.900000    3.650000        136.900000   265.450000  1.350000   \n",
       "\n",
       "               max_heart_rate  ST_depression  Peak_ST_seg  major_vessels  \\\n",
       "major_vessels                                                              \n",
       "False              137.612235       0.861359     1.847778       0.165556   \n",
       "True               134.550000       1.865000     1.850000       3.000000   \n",
       "\n",
       "                   thal  has_heart_disease  \n",
       "major_vessels                               \n",
       "False          5.566667           0.966667  \n",
       "True           5.700000           2.300000  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_imputed.groupby(by=df_imputed.major_vessels>2).mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### One Hot Encoding of Categorical Variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>chest_1</th>\n",
       "      <th>chest_2</th>\n",
       "      <th>chest_3</th>\n",
       "      <th>chest_4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   chest_1  chest_2  chest_3  chest_4\n",
       "0        1        0        0        0\n",
       "1        0        0        0        1\n",
       "2        0        0        0        1\n",
       "3        0        0        1        0\n",
       "4        0        1        0        0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# one hot encoded variables can be created using the get_dummies variable\n",
    "tmpdf = pd.get_dummies(df_imputed['chest_pain'],prefix='chest')\n",
    "\n",
    "tmpdf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>is_male_0</th>\n",
       "      <th>is_male_1</th>\n",
       "      <th>high_blood_sugar_0.0</th>\n",
       "      <th>high_blood_sugar_0</th>\n",
       "      <th>high_blood_sugar_1</th>\n",
       "      <th>exer_angina_0.0</th>\n",
       "      <th>exer_angina_0</th>\n",
       "      <th>exer_angina_1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   is_male_0  is_male_1  high_blood_sugar_0.0  high_blood_sugar_0  \\\n",
       "0          0          1                     0                   0   \n",
       "1          0          1                     0                   1   \n",
       "2          0          1                     0                   1   \n",
       "3          0          1                     0                   1   \n",
       "4          1          0                     0                   1   \n",
       "\n",
       "   high_blood_sugar_1  exer_angina_0.0  exer_angina_0  exer_angina_1  \n",
       "0                   1                0              1              0  \n",
       "1                   0                0              0              1  \n",
       "2                   0                0              0              1  \n",
       "3                   0                0              1              0  \n",
       "4                   0                0              1              0  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#one hot encoding of ALL categorical variables\n",
    "# there is lot going on in this one line of code, so let's step through it\n",
    "\n",
    "# pd.concat([*]], axis=1) // this line of code concatenates all the data frames in the [*] list\n",
    "# [** for col in categ_features] // this steps through each feature in categ_features and \n",
    "#                                //   creates a new element in a list based on the output of **\n",
    "# pd.get_dummies(df_imputed[col],prefix=col) // this creates a one hot encoded dataframe of the variable=col (like code above)\n",
    "\n",
    "one_hot_df = pd.concat([pd.get_dummies(df_imputed[col],prefix=col) for col in categ_features], axis=1)\n",
    "\n",
    "one_hot_df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calling R from iPython (optional)\n",
    "\n",
    "- Note: you will need R installed on your machine to run these!!\n",
    "\n",
    "iPython has a lot of interesting \"magics\" built in. If you use R and have it installed on your machine, then you can write and look at R code directly from iPython cells. R also uses data frames, which we can push data into directly from the Pandas object we are using:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/eclarson/anaconda/envs/MLEnv/lib/python3.5/site-packages/IPython/extensions/rmagic.py:11: UserWarning: The rmagic extension in IPython has moved to `rpy2.ipython`, please see `rpy2` documentation.\n",
      "  warnings.warn(\"The rmagic extension in IPython has moved to \"\n"
     ]
    }
   ],
   "source": [
    "# CONVERT PANDAS DATAFRAME TO R DATA.FRAME\n",
    "# adapted from: http://tagteam.harvard.edu/hub_feeds/1981/feed_items/196017\n",
    "# I have better luck with both calls here\n",
    "\n",
    "%load_ext rmagic\n",
    "%load_ext rpy2.ipython\n",
    "\n",
    "df_colnames = df_imputed.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['age', 'is_male', 'chest_pain', 'rest_blood_press', 'cholesterol',\n",
       "       'high_blood_sugar', 'rest_ecg', 'max_heart_rate', 'exer_angina',\n",
       "       'ST_depression', 'Peak_ST_seg', 'major_vessels', 'thal',\n",
       "       'has_heart_disease'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_colnames"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now lets take the data frame from pandas and tell Rmagics that we want to have variables available in the R workspace. We use the %%R command to tell iPython that the entire cell is R code. The \"-i\" tells Rmagics that we want to transfer those variables over to R.\n",
    "\n",
    "The following code will take the variables df_imputed and df_colnames into the R workspace and test if they are truly saved as R data.frames type variables."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1] TRUE\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%R -i df_imputed,df_colnames \n",
    "\n",
    "colnames(df_imputed) <- unlist(df_colnames); \n",
    "print(is.data.frame(df_imputed))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Theay were data.frames! Great. Let's call an R function on the data.frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      age        is_male   chest_pain   rest_blood_press  cholesterol   \n",
       " Min.   :28.00   0:194   Min.   :1.00   Min.   :  0.0    Min.   :  0.0  \n",
       " 1st Qu.:47.00   1:726   1st Qu.:3.00   1st Qu.:120.0    1st Qu.:177.8  \n",
       " Median :54.00           Median :4.00   Median :130.0    Median :221.0  \n",
       " Mean   :53.51           Mean   :3.25   Mean   :132.1    Mean   :199.1  \n",
       " 3rd Qu.:60.00           3rd Qu.:4.00   3rd Qu.:140.0    3rd Qu.:267.0  \n",
       " Max.   :77.00           Max.   :4.00   Max.   :200.0    Max.   :603.0  \n",
       " high_blood_sugar.0 high_blood_sugar.1 high_blood_sugar.2 high_blood_sugar.3\n",
       " 1:920              0:920              0:920              0:920             \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       " high_blood_sugar.4 high_blood_sugar.5 high_blood_sugar.6 high_blood_sugar.7\n",
       " 0:920              0:920              0:920              0:920             \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       "                                                                            \n",
       " high_blood_sugar.8 high_blood_sugar.9 high_blood_sugar.10 high_blood_sugar.11\n",
       " 0:920              1:920              0:920               0:920              \n",
       "                                                                              \n",
       "                                                                              \n",
       "                                                                              \n",
       "                                                                              \n",
       "                                                                              \n",
       " high_blood_sugar.12 high_blood_sugar.13 high_blood_sugar.14\n",
       " 1:920               0:920               1:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.15 high_blood_sugar.16 high_blood_sugar.17\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.18 high_blood_sugar.19 high_blood_sugar.20\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.21 high_blood_sugar.22 high_blood_sugar.23\n",
       " 1:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.24 high_blood_sugar.25 high_blood_sugar.26\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.27 high_blood_sugar.28 high_blood_sugar.29\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.30 high_blood_sugar.31 high_blood_sugar.32\n",
       " 0:920               1:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.33 high_blood_sugar.34 high_blood_sugar.35\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.36 high_blood_sugar.37 high_blood_sugar.38\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.39 high_blood_sugar.40 high_blood_sugar.41\n",
       " 1:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.42 high_blood_sugar.43 high_blood_sugar.44\n",
       " 0:920               1:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.45 high_blood_sugar.46 high_blood_sugar.47\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.48 high_blood_sugar.49 high_blood_sugar.50\n",
       " 1:920               1:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.51 high_blood_sugar.52 high_blood_sugar.53\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.54 high_blood_sugar.55 high_blood_sugar.56\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.57 high_blood_sugar.58 high_blood_sugar.59\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.60 high_blood_sugar.61 high_blood_sugar.62\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.63 high_blood_sugar.64 high_blood_sugar.65\n",
       " 1:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.66 high_blood_sugar.67 high_blood_sugar.68\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.69 high_blood_sugar.70 high_blood_sugar.71\n",
       " 0:920               0:920               1:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.72 high_blood_sugar.73 high_blood_sugar.74\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.75 high_blood_sugar.76 high_blood_sugar.77\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.78 high_blood_sugar.79 high_blood_sugar.80\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.81 high_blood_sugar.82 high_blood_sugar.83\n",
       " 0:920               0:920               1:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.84 high_blood_sugar.85 high_blood_sugar.86\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.87 high_blood_sugar.88 high_blood_sugar.89\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.90 high_blood_sugar.91 high_blood_sugar.92\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.93 high_blood_sugar.94 high_blood_sugar.95\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.96 high_blood_sugar.97 high_blood_sugar.98\n",
       " 0:920               0:920               0:920              \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       "                                                            \n",
       " high_blood_sugar.99 high_blood_sugar.100 high_blood_sugar.101\n",
       " 0:920               0:920                0:920               \n",
       "                                                              \n",
       "                                                              \n",
       "                                                              \n",
       "                                                              \n",
       "                                                              \n",
       " high_blood_sugar.102 high_blood_sugar.103 high_blood_sugar.104\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.105 high_blood_sugar.106 high_blood_sugar.107\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.108 high_blood_sugar.109 high_blood_sugar.110\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.111 high_blood_sugar.112 high_blood_sugar.113\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.114 high_blood_sugar.115 high_blood_sugar.116\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.117 high_blood_sugar.118 high_blood_sugar.119\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.120 high_blood_sugar.121 high_blood_sugar.122\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.123 high_blood_sugar.124 high_blood_sugar.125\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.126 high_blood_sugar.127 high_blood_sugar.128\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.129 high_blood_sugar.130 high_blood_sugar.131\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.132 high_blood_sugar.133 high_blood_sugar.134\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.135 high_blood_sugar.136 high_blood_sugar.137\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.138 high_blood_sugar.139 high_blood_sugar.140\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.141 high_blood_sugar.142 high_blood_sugar.143\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.144 high_blood_sugar.145 high_blood_sugar.146\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.147 high_blood_sugar.148 high_blood_sugar.149\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.150 high_blood_sugar.151 high_blood_sugar.152\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.153 high_blood_sugar.154 high_blood_sugar.155\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.156 high_blood_sugar.157 high_blood_sugar.158\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.159 high_blood_sugar.160 high_blood_sugar.161\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.162 high_blood_sugar.163 high_blood_sugar.164\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.165 high_blood_sugar.166 high_blood_sugar.167\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.168 high_blood_sugar.169 high_blood_sugar.170\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.171 high_blood_sugar.172 high_blood_sugar.173\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.174 high_blood_sugar.175 high_blood_sugar.176\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.177 high_blood_sugar.178 high_blood_sugar.179\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.180 high_blood_sugar.181 high_blood_sugar.182\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.183 high_blood_sugar.184 high_blood_sugar.185\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.186 high_blood_sugar.187 high_blood_sugar.188\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.189 high_blood_sugar.190 high_blood_sugar.191\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.192 high_blood_sugar.193 high_blood_sugar.194\n",
       " 1:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.195 high_blood_sugar.196 high_blood_sugar.197\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.198 high_blood_sugar.199 high_blood_sugar.200\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.201 high_blood_sugar.202 high_blood_sugar.203\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.204 high_blood_sugar.205 high_blood_sugar.206\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.207 high_blood_sugar.208 high_blood_sugar.209\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.210 high_blood_sugar.211 high_blood_sugar.212\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.213 high_blood_sugar.214 high_blood_sugar.215\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.216 high_blood_sugar.217 high_blood_sugar.218\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.219 high_blood_sugar.220 high_blood_sugar.221\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.222 high_blood_sugar.223 high_blood_sugar.224\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.225 high_blood_sugar.226 high_blood_sugar.227\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.228 high_blood_sugar.229 high_blood_sugar.230\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.231 high_blood_sugar.232 high_blood_sugar.233\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.234 high_blood_sugar.235 high_blood_sugar.236\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.237 high_blood_sugar.238 high_blood_sugar.239\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.240 high_blood_sugar.241 high_blood_sugar.242\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.243 high_blood_sugar.244 high_blood_sugar.245\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.246 high_blood_sugar.247 high_blood_sugar.248\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.249 high_blood_sugar.250 high_blood_sugar.251\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.252 high_blood_sugar.253 high_blood_sugar.254\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.255 high_blood_sugar.256 high_blood_sugar.257\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.258 high_blood_sugar.259 high_blood_sugar.260\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.261 high_blood_sugar.262 high_blood_sugar.263\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.264 high_blood_sugar.265 high_blood_sugar.266\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.267 high_blood_sugar.268 high_blood_sugar.269\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.270 high_blood_sugar.271 high_blood_sugar.272\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.273 high_blood_sugar.274 high_blood_sugar.275\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.276 high_blood_sugar.277 high_blood_sugar.278\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.279 high_blood_sugar.280 high_blood_sugar.281\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.282 high_blood_sugar.283 high_blood_sugar.284\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.285 high_blood_sugar.286 high_blood_sugar.287\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.288 high_blood_sugar.289 high_blood_sugar.290\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.291 high_blood_sugar.292 high_blood_sugar.293\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.294 high_blood_sugar.295 high_blood_sugar.296\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.297 high_blood_sugar.298 high_blood_sugar.299\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.300 high_blood_sugar.301 high_blood_sugar.302\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.303 high_blood_sugar.304 high_blood_sugar.305\n",
       " Min.   :0            Min.   :0            Min.   :0           \n",
       " 1st Qu.:0            1st Qu.:0            1st Qu.:0           \n",
       " Median :0            Median :0            Median :0           \n",
       " Mean   :0            Mean   :0            Mean   :0           \n",
       " 3rd Qu.:0            3rd Qu.:0            3rd Qu.:0           \n",
       " Max.   :0            Max.   :0            Max.   :0           \n",
       " high_blood_sugar.306 high_blood_sugar.307 high_blood_sugar.308\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.309 high_blood_sugar.310 high_blood_sugar.311\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.312 high_blood_sugar.313 high_blood_sugar.314\n",
       " Min.   :0            Min.   :0            Min.   :0           \n",
       " 1st Qu.:0            1st Qu.:0            1st Qu.:0           \n",
       " Median :0            Median :0            Median :0           \n",
       " Mean   :0            Mean   :0            Mean   :0           \n",
       " 3rd Qu.:0            3rd Qu.:0            3rd Qu.:0           \n",
       " Max.   :0            Max.   :0            Max.   :0           \n",
       " high_blood_sugar.315 high_blood_sugar.316 high_blood_sugar.317\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.318 high_blood_sugar.319 high_blood_sugar.320\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.321 high_blood_sugar.322 high_blood_sugar.323\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.324 high_blood_sugar.325 high_blood_sugar.326\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.327 high_blood_sugar.328 high_blood_sugar.329\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.330 high_blood_sugar.331 high_blood_sugar.332\n",
       " 0:920                Min.   :0            Min.   :0           \n",
       "                      1st Qu.:0            1st Qu.:0           \n",
       "                      Median :0            Median :0           \n",
       "                      Mean   :0            Mean   :0           \n",
       "                      3rd Qu.:0            3rd Qu.:0           \n",
       "                      Max.   :0            Max.   :0           \n",
       " high_blood_sugar.333 high_blood_sugar.334 high_blood_sugar.335\n",
       " Min.   :0            1:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.336 high_blood_sugar.337 high_blood_sugar.338\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.339 high_blood_sugar.340 high_blood_sugar.341\n",
       " Min.   :0            Min.   :0            Min.   :0           \n",
       " 1st Qu.:0            1st Qu.:0            1st Qu.:0           \n",
       " Median :0            Median :0            Median :0           \n",
       " Mean   :0            Mean   :0            Mean   :0           \n",
       " 3rd Qu.:0            3rd Qu.:0            3rd Qu.:0           \n",
       " Max.   :0            Max.   :0            Max.   :0           \n",
       " high_blood_sugar.342 high_blood_sugar.343 high_blood_sugar.344\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.345 high_blood_sugar.346 high_blood_sugar.347\n",
       " 0:920                Min.   :0            Min.   :0           \n",
       "                      1st Qu.:0            1st Qu.:0           \n",
       "                      Median :0            Median :0           \n",
       "                      Mean   :0            Mean   :0           \n",
       "                      3rd Qu.:0            3rd Qu.:0           \n",
       "                      Max.   :0            Max.   :0           \n",
       " high_blood_sugar.348 high_blood_sugar.349 high_blood_sugar.350\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.351 high_blood_sugar.352 high_blood_sugar.353\n",
       " 0:920                Min.   :0            Min.   :0           \n",
       "                      1st Qu.:0            1st Qu.:0           \n",
       "                      Median :0            Median :0           \n",
       "                      Mean   :0            Mean   :0           \n",
       "                      3rd Qu.:0            3rd Qu.:0           \n",
       "                      Max.   :0            Max.   :0           \n",
       " high_blood_sugar.354 high_blood_sugar.355 high_blood_sugar.356\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.357 high_blood_sugar.358 high_blood_sugar.359\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.360 high_blood_sugar.361 high_blood_sugar.362\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.363 high_blood_sugar.364 high_blood_sugar.365\n",
       " 0:920                1:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.366 high_blood_sugar.367 high_blood_sugar.368\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.369 high_blood_sugar.370 high_blood_sugar.371\n",
       " Min.   :0            Min.   :0            Min.   :0           \n",
       " 1st Qu.:0            1st Qu.:0            1st Qu.:0           \n",
       " Median :0            Median :0            Median :0           \n",
       " Mean   :0            Mean   :0            Mean   :0           \n",
       " 3rd Qu.:0            3rd Qu.:0            3rd Qu.:0           \n",
       " Max.   :0            Max.   :0            Max.   :0           \n",
       " high_blood_sugar.372 high_blood_sugar.373 high_blood_sugar.374\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.375 high_blood_sugar.376 high_blood_sugar.377\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.378 high_blood_sugar.379 high_blood_sugar.380\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.381 high_blood_sugar.382 high_blood_sugar.383\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.384 high_blood_sugar.385 high_blood_sugar.386\n",
       " 0:920                Min.   :0            Min.   :0           \n",
       "                      1st Qu.:0            1st Qu.:0           \n",
       "                      Median :0            Median :0           \n",
       "                      Mean   :0            Mean   :0           \n",
       "                      3rd Qu.:0            3rd Qu.:0           \n",
       "                      Max.   :0            Max.   :0           \n",
       " high_blood_sugar.387 high_blood_sugar.388 high_blood_sugar.389\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.390 high_blood_sugar.391 high_blood_sugar.392\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.393 high_blood_sugar.394 high_blood_sugar.395\n",
       " 0:920                1:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.396 high_blood_sugar.397 high_blood_sugar.398\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.399 high_blood_sugar.400 high_blood_sugar.401\n",
       " Min.   :0            Min.   :0            Min.   :0           \n",
       " 1st Qu.:0            1st Qu.:0            1st Qu.:0           \n",
       " Median :0            Median :0            Median :0           \n",
       " Mean   :0            Mean   :0            Mean   :0           \n",
       " 3rd Qu.:0            3rd Qu.:0            3rd Qu.:0           \n",
       " Max.   :0            Max.   :0            Max.   :0           \n",
       " high_blood_sugar.402 high_blood_sugar.403 high_blood_sugar.404\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.405 high_blood_sugar.406 high_blood_sugar.407\n",
       " Min.   :0            0:920                0:920               \n",
       " 1st Qu.:0                                                     \n",
       " Median :0                                                     \n",
       " Mean   :0                                                     \n",
       " 3rd Qu.:0                                                     \n",
       " Max.   :0                                                     \n",
       " high_blood_sugar.408 high_blood_sugar.409 high_blood_sugar.410\n",
       " Min.   :0            Min.   :0            0:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.411 high_blood_sugar.412 high_blood_sugar.413\n",
       " Min.   :0            Min.   :0            1:920               \n",
       " 1st Qu.:0            1st Qu.:0                                \n",
       " Median :0            Median :0                                \n",
       " Mean   :0            Mean   :0                                \n",
       " 3rd Qu.:0            3rd Qu.:0                                \n",
       " Max.   :0            Max.   :0                                \n",
       " high_blood_sugar.414 high_blood_sugar.415 high_blood_sugar.416\n",
       " Min.   :0            0:920                0:920               \n",
       " 1st Qu.:0                                                     \n",
       " Median :0                                                     \n",
       " Mean   :0                                                     \n",
       " 3rd Qu.:0                                                     \n",
       " Max.   :0                                                     \n",
       " high_blood_sugar.417 high_blood_sugar.418 high_blood_sugar.419\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.420 high_blood_sugar.421 high_blood_sugar.422\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.423 high_blood_sugar.424 high_blood_sugar.425\n",
       " Min.   :0            0:920                Min.   :0           \n",
       " 1st Qu.:0                                 1st Qu.:0           \n",
       " Median :0                                 Median :0           \n",
       " Mean   :0                                 Mean   :0           \n",
       " 3rd Qu.:0                                 3rd Qu.:0           \n",
       " Max.   :0                                 Max.   :0           \n",
       " high_blood_sugar.426 high_blood_sugar.427 high_blood_sugar.428\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.429 high_blood_sugar.430 high_blood_sugar.431\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.432 high_blood_sugar.433 high_blood_sugar.434\n",
       " 1:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.435 high_blood_sugar.436 high_blood_sugar.437\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.438 high_blood_sugar.439 high_blood_sugar.440\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.441 high_blood_sugar.442 high_blood_sugar.443\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.444 high_blood_sugar.445 high_blood_sugar.446\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.447 high_blood_sugar.448 high_blood_sugar.449\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.450 high_blood_sugar.451 high_blood_sugar.452\n",
       " 0:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.453 high_blood_sugar.454 high_blood_sugar.455\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.456 high_blood_sugar.457 high_blood_sugar.458\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.459 high_blood_sugar.460 high_blood_sugar.461\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.462 high_blood_sugar.463 high_blood_sugar.464\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.465 high_blood_sugar.466 high_blood_sugar.467\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.468 high_blood_sugar.469 high_blood_sugar.470\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.471 high_blood_sugar.472 high_blood_sugar.473\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.474 high_blood_sugar.475 high_blood_sugar.476\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.477 high_blood_sugar.478 high_blood_sugar.479\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.480 high_blood_sugar.481 high_blood_sugar.482\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.483 high_blood_sugar.484 high_blood_sugar.485\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.486 high_blood_sugar.487 high_blood_sugar.488\n",
       " 1:920                Min.   :0            Min.   :0           \n",
       "                      1st Qu.:0            1st Qu.:0           \n",
       "                      Median :0            Median :0           \n",
       "                      Mean   :0            Mean   :0           \n",
       "                      3rd Qu.:0            3rd Qu.:0           \n",
       "                      Max.   :0            Max.   :0           \n",
       " high_blood_sugar.489 high_blood_sugar.490 high_blood_sugar.491\n",
       " 0:920                1:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.492 high_blood_sugar.493 high_blood_sugar.494\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.495 high_blood_sugar.496 high_blood_sugar.497\n",
       " 1:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.498 high_blood_sugar.499 high_blood_sugar.500\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.501 high_blood_sugar.502 high_blood_sugar.503\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.504 high_blood_sugar.505 high_blood_sugar.506\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.507 high_blood_sugar.508 high_blood_sugar.509\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.510 high_blood_sugar.511 high_blood_sugar.512\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.513 high_blood_sugar.514 high_blood_sugar.515\n",
       " 1:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.516 high_blood_sugar.517 high_blood_sugar.518\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.519 high_blood_sugar.520 high_blood_sugar.521\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.522 high_blood_sugar.523 high_blood_sugar.524\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.525 high_blood_sugar.526 high_blood_sugar.527\n",
       " 1:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.528 high_blood_sugar.529 high_blood_sugar.530\n",
       " Min.   :0            0:920                0:920               \n",
       " 1st Qu.:0                                                     \n",
       " Median :0                                                     \n",
       " Mean   :0                                                     \n",
       " 3rd Qu.:0                                                     \n",
       " Max.   :0                                                     \n",
       " high_blood_sugar.531 high_blood_sugar.532 high_blood_sugar.533\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.534 high_blood_sugar.535 high_blood_sugar.536\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.537 high_blood_sugar.538 high_blood_sugar.539\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.540 high_blood_sugar.541 high_blood_sugar.542\n",
       " 0:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.543 high_blood_sugar.544 high_blood_sugar.545\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.546 high_blood_sugar.547 high_blood_sugar.548\n",
       " 1:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.549 high_blood_sugar.550 high_blood_sugar.551\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.552 high_blood_sugar.553 high_blood_sugar.554\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.555 high_blood_sugar.556 high_blood_sugar.557\n",
       " 0:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.558 high_blood_sugar.559 high_blood_sugar.560\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.561 high_blood_sugar.562 high_blood_sugar.563\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.564 high_blood_sugar.565 high_blood_sugar.566\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.567 high_blood_sugar.568 high_blood_sugar.569\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.570 high_blood_sugar.571 high_blood_sugar.572\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.573 high_blood_sugar.574 high_blood_sugar.575\n",
       " 1:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.576 high_blood_sugar.577 high_blood_sugar.578\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.579 high_blood_sugar.580 high_blood_sugar.581\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.582 high_blood_sugar.583 high_blood_sugar.584\n",
       " 0:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.585 high_blood_sugar.586 high_blood_sugar.587\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.588 high_blood_sugar.589 high_blood_sugar.590\n",
       " 0:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.591 high_blood_sugar.592 high_blood_sugar.593\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.594 high_blood_sugar.595 high_blood_sugar.596\n",
       " 1:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.597 high_blood_sugar.598 high_blood_sugar.599\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.600 high_blood_sugar.601 high_blood_sugar.602\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.603 high_blood_sugar.604 high_blood_sugar.605\n",
       " 1:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.606 high_blood_sugar.607 high_blood_sugar.608\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.609 high_blood_sugar.610 high_blood_sugar.611\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.612 high_blood_sugar.613 high_blood_sugar.614\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.615 high_blood_sugar.616 high_blood_sugar.617\n",
       " 1:920                1:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.618 high_blood_sugar.619 high_blood_sugar.620\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.621 high_blood_sugar.622 high_blood_sugar.623\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.624 high_blood_sugar.625 high_blood_sugar.626\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.627 high_blood_sugar.628 high_blood_sugar.629\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.630 high_blood_sugar.631 high_blood_sugar.632\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.633 high_blood_sugar.634 high_blood_sugar.635\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.636 high_blood_sugar.637 high_blood_sugar.638\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.639 high_blood_sugar.640 high_blood_sugar.641\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.642 high_blood_sugar.643 high_blood_sugar.644\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.645 high_blood_sugar.646 high_blood_sugar.647\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.648 high_blood_sugar.649 high_blood_sugar.650\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.651 high_blood_sugar.652 high_blood_sugar.653\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.654 high_blood_sugar.655 high_blood_sugar.656\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.657 high_blood_sugar.658 high_blood_sugar.659\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.660 high_blood_sugar.661 high_blood_sugar.662\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.663 high_blood_sugar.664 high_blood_sugar.665\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.666 high_blood_sugar.667 high_blood_sugar.668\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.669 high_blood_sugar.670 high_blood_sugar.671\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.672 high_blood_sugar.673 high_blood_sugar.674\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.675 high_blood_sugar.676 high_blood_sugar.677\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.678 high_blood_sugar.679 high_blood_sugar.680\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.681 high_blood_sugar.682 high_blood_sugar.683\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.684 high_blood_sugar.685 high_blood_sugar.686\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.687 high_blood_sugar.688 high_blood_sugar.689\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.690 high_blood_sugar.691 high_blood_sugar.692\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.693 high_blood_sugar.694 high_blood_sugar.695\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.696 high_blood_sugar.697 high_blood_sugar.698\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.699 high_blood_sugar.700 high_blood_sugar.701\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.702 high_blood_sugar.703 high_blood_sugar.704\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.705 high_blood_sugar.706 high_blood_sugar.707\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.708 high_blood_sugar.709 high_blood_sugar.710\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.711 high_blood_sugar.712 high_blood_sugar.713\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.714 high_blood_sugar.715 high_blood_sugar.716\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.717 high_blood_sugar.718 high_blood_sugar.719\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.720 high_blood_sugar.721 high_blood_sugar.722\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.723 high_blood_sugar.724 high_blood_sugar.725\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.726 high_blood_sugar.727 high_blood_sugar.728\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.729 high_blood_sugar.730 high_blood_sugar.731\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.732 high_blood_sugar.733 high_blood_sugar.734\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.735 high_blood_sugar.736 high_blood_sugar.737\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.738 high_blood_sugar.739 high_blood_sugar.740\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.741 high_blood_sugar.742 high_blood_sugar.743\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.744 high_blood_sugar.745 high_blood_sugar.746\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.747 high_blood_sugar.748 high_blood_sugar.749\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.750 high_blood_sugar.751 high_blood_sugar.752\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.753 high_blood_sugar.754 high_blood_sugar.755\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.756 high_blood_sugar.757 high_blood_sugar.758\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.759 high_blood_sugar.760 high_blood_sugar.761\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.762 high_blood_sugar.763 high_blood_sugar.764\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.765 high_blood_sugar.766 high_blood_sugar.767\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.768 high_blood_sugar.769 high_blood_sugar.770\n",
       " 0:920                0:920                Min.   :0           \n",
       "                                           1st Qu.:0           \n",
       "                                           Median :0           \n",
       "                                           Mean   :0           \n",
       "                                           3rd Qu.:0           \n",
       "                                           Max.   :0           \n",
       " high_blood_sugar.771 high_blood_sugar.772 high_blood_sugar.773\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.774 high_blood_sugar.775 high_blood_sugar.776\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.777 high_blood_sugar.778 high_blood_sugar.779\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.780 high_blood_sugar.781 high_blood_sugar.782\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.783 high_blood_sugar.784 high_blood_sugar.785\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.786 high_blood_sugar.787 high_blood_sugar.788\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.789 high_blood_sugar.790 high_blood_sugar.791\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.792 high_blood_sugar.793 high_blood_sugar.794\n",
       " Min.   :0            0:920                0:920               \n",
       " 1st Qu.:0                                                     \n",
       " Median :0                                                     \n",
       " Mean   :0                                                     \n",
       " 3rd Qu.:0                                                     \n",
       " Max.   :0                                                     \n",
       " high_blood_sugar.795 high_blood_sugar.796 high_blood_sugar.797\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.798 high_blood_sugar.799 high_blood_sugar.800\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.801 high_blood_sugar.802 high_blood_sugar.803\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.804 high_blood_sugar.805 high_blood_sugar.806\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.807 high_blood_sugar.808 high_blood_sugar.809\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.810 high_blood_sugar.811 high_blood_sugar.812\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.813 high_blood_sugar.814 high_blood_sugar.815\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.816 high_blood_sugar.817 high_blood_sugar.818\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.819 high_blood_sugar.820 high_blood_sugar.821\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.822 high_blood_sugar.823 high_blood_sugar.824\n",
       " 0:920                Min.   :0            0:920               \n",
       "                      1st Qu.:0                                \n",
       "                      Median :0                                \n",
       "                      Mean   :0                                \n",
       "                      3rd Qu.:0                                \n",
       "                      Max.   :0                                \n",
       " high_blood_sugar.825 high_blood_sugar.826 high_blood_sugar.827\n",
       " Min.   :0            0:920                0:920               \n",
       " 1st Qu.:0                                                     \n",
       " Median :0                                                     \n",
       " Mean   :0                                                     \n",
       " 3rd Qu.:0                                                     \n",
       " Max.   :0                                                     \n",
       " high_blood_sugar.828 high_blood_sugar.829 high_blood_sugar.830\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.831 high_blood_sugar.832 high_blood_sugar.833\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.834 high_blood_sugar.835 high_blood_sugar.836\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.837 high_blood_sugar.838 high_blood_sugar.839\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.840 high_blood_sugar.841 high_blood_sugar.842\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.843 high_blood_sugar.844 high_blood_sugar.845\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.846 high_blood_sugar.847 high_blood_sugar.848\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.849 high_blood_sugar.850 high_blood_sugar.851\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.852 high_blood_sugar.853 high_blood_sugar.854\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.855 high_blood_sugar.856 high_blood_sugar.857\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.858 high_blood_sugar.859 high_blood_sugar.860\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.861 high_blood_sugar.862 high_blood_sugar.863\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.864 high_blood_sugar.865 high_blood_sugar.866\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.867 high_blood_sugar.868 high_blood_sugar.869\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.870 high_blood_sugar.871 high_blood_sugar.872\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.873 high_blood_sugar.874 high_blood_sugar.875\n",
       " 1:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.876 high_blood_sugar.877 high_blood_sugar.878\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.879 high_blood_sugar.880 high_blood_sugar.881\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.882 high_blood_sugar.883 high_blood_sugar.884\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.885 high_blood_sugar.886 high_blood_sugar.887\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.888 high_blood_sugar.889 high_blood_sugar.890\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.891 high_blood_sugar.892 high_blood_sugar.893\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.894 high_blood_sugar.895 high_blood_sugar.896\n",
       " 0:920                1:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.897 high_blood_sugar.898 high_blood_sugar.899\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.900 high_blood_sugar.901 high_blood_sugar.902\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.903 high_blood_sugar.904 high_blood_sugar.905\n",
       " 1:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.906 high_blood_sugar.907 high_blood_sugar.908\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.909 high_blood_sugar.910 high_blood_sugar.911\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.912 high_blood_sugar.913 high_blood_sugar.914\n",
       " 0:920                0:920                0:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.915 high_blood_sugar.916 high_blood_sugar.917\n",
       " 0:920                0:920                1:920               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       "                                                               \n",
       " high_blood_sugar.918 high_blood_sugar.919    rest_ecg      max_heart_rate \n",
       " 0:920                0:920                Min.   :0.0000   Min.   : 60.0  \n",
       "                                           1st Qu.:0.0000   1st Qu.:120.0  \n",
       "                                           Median :0.0000   Median :138.0  \n",
       "                                           Mean   :0.6033   Mean   :137.5  \n",
       "                                           3rd Qu.:1.0000   3rd Qu.:156.0  \n",
       "                                           Max.   :2.0000   Max.   :202.0  \n",
       " exer_angina.0 exer_angina.1 exer_angina.2 exer_angina.3 exer_angina.4\n",
       " 0:920         1:920         1:920         0:920         0:920        \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       " exer_angina.5 exer_angina.6 exer_angina.7 exer_angina.8 exer_angina.9\n",
       " 0:920         0:920         1:920         0:920         1:920        \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       "                                                                      \n",
       " exer_angina.10 exer_angina.11 exer_angina.12 exer_angina.13 exer_angina.14\n",
       " 0:920          0:920          1:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.15 exer_angina.16 exer_angina.17 exer_angina.18 exer_angina.19\n",
       " 0:920          0:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.20 exer_angina.21 exer_angina.22 exer_angina.23 exer_angina.24\n",
       " 1:920          0:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.25 exer_angina.26 exer_angina.27 exer_angina.28 exer_angina.29\n",
       " 0:920          0:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.30 exer_angina.31 exer_angina.32 exer_angina.33 exer_angina.34\n",
       " 0:920          1:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.35 exer_angina.36 exer_angina.37 exer_angina.38 exer_angina.39\n",
       " 0:920          1:920          1:920          1:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.40 exer_angina.41 exer_angina.42 exer_angina.43 exer_angina.44\n",
       " 0:920          1:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.45 exer_angina.46 exer_angina.47 exer_angina.48 exer_angina.49\n",
       " 0:920          0:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.50 exer_angina.51 exer_angina.52 exer_angina.53 exer_angina.54\n",
       " 0:920          0:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.55 exer_angina.56 exer_angina.57 exer_angina.58 exer_angina.59\n",
       " 1:920          0:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.60 exer_angina.61 exer_angina.62 exer_angina.63 exer_angina.64\n",
       " 1:920          1:920          1:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.65 exer_angina.66 exer_angina.67 exer_angina.68 exer_angina.69\n",
       " 1:920          0:920          0:920          1:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.70 exer_angina.71 exer_angina.72 exer_angina.73 exer_angina.74\n",
       " 0:920          0:920          1:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.75 exer_angina.76 exer_angina.77 exer_angina.78 exer_angina.79\n",
       " 0:920          1:920          0:920          0:920          1:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.80 exer_angina.81 exer_angina.82 exer_angina.83 exer_angina.84\n",
       " 1:920          0:920          0:920          1:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.85 exer_angina.86 exer_angina.87 exer_angina.88 exer_angina.89\n",
       " 0:920          0:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.90 exer_angina.91 exer_angina.92 exer_angina.93 exer_angina.94\n",
       " 0:920          0:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.95 exer_angina.96 exer_angina.97 exer_angina.98 exer_angina.99\n",
       " 1:920          1:920          0:920          0:920          0:920         \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       "                                                                           \n",
       " exer_angina.100 exer_angina.101 exer_angina.102 exer_angina.103\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.104 exer_angina.105 exer_angina.106 exer_angina.107\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.108 exer_angina.109 exer_angina.110 exer_angina.111\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.112 exer_angina.113 exer_angina.114 exer_angina.115\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.116 exer_angina.117 exer_angina.118 exer_angina.119\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.120 exer_angina.121 exer_angina.122 exer_angina.123\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.124 exer_angina.125 exer_angina.126 exer_angina.127\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.128 exer_angina.129 exer_angina.130 exer_angina.131\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.132 exer_angina.133 exer_angina.134 exer_angina.135\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.136 exer_angina.137 exer_angina.138 exer_angina.139\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.140 exer_angina.141 exer_angina.142 exer_angina.143\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.144 exer_angina.145 exer_angina.146 exer_angina.147\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.148 exer_angina.149 exer_angina.150 exer_angina.151\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.152 exer_angina.153 exer_angina.154 exer_angina.155\n",
       " 0:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.156 exer_angina.157 exer_angina.158 exer_angina.159\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.160 exer_angina.161 exer_angina.162 exer_angina.163\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.164 exer_angina.165 exer_angina.166 exer_angina.167\n",
       " 0:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.168 exer_angina.169 exer_angina.170 exer_angina.171\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.172 exer_angina.173 exer_angina.174 exer_angina.175\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.176 exer_angina.177 exer_angina.178 exer_angina.179\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.180 exer_angina.181 exer_angina.182 exer_angina.183\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.184 exer_angina.185 exer_angina.186 exer_angina.187\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.188 exer_angina.189 exer_angina.190 exer_angina.191\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.192 exer_angina.193 exer_angina.194 exer_angina.195\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.196 exer_angina.197 exer_angina.198 exer_angina.199\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.200 exer_angina.201 exer_angina.202 exer_angina.203\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.204 exer_angina.205 exer_angina.206 exer_angina.207\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.208 exer_angina.209 exer_angina.210 exer_angina.211\n",
       " 0:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.212 exer_angina.213 exer_angina.214 exer_angina.215\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.216 exer_angina.217 exer_angina.218 exer_angina.219\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.220 exer_angina.221 exer_angina.222 exer_angina.223\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.224 exer_angina.225 exer_angina.226 exer_angina.227\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.228 exer_angina.229 exer_angina.230 exer_angina.231\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.232 exer_angina.233 exer_angina.234 exer_angina.235\n",
       " 0:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.236 exer_angina.237 exer_angina.238 exer_angina.239\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.240 exer_angina.241 exer_angina.242 exer_angina.243\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.244 exer_angina.245 exer_angina.246 exer_angina.247\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.248 exer_angina.249 exer_angina.250 exer_angina.251\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.252 exer_angina.253 exer_angina.254 exer_angina.255\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.256 exer_angina.257 exer_angina.258 exer_angina.259\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.260 exer_angina.261 exer_angina.262 exer_angina.263\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.264 exer_angina.265 exer_angina.266 exer_angina.267\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.268 exer_angina.269 exer_angina.270 exer_angina.271\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.272 exer_angina.273 exer_angina.274 exer_angina.275\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.276 exer_angina.277 exer_angina.278 exer_angina.279\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.280 exer_angina.281 exer_angina.282 exer_angina.283\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.284 exer_angina.285 exer_angina.286 exer_angina.287\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.288 exer_angina.289 exer_angina.290 exer_angina.291\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.292 exer_angina.293 exer_angina.294 exer_angina.295\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.296 exer_angina.297 exer_angina.298 exer_angina.299\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.300 exer_angina.301 exer_angina.302 exer_angina.303\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.304 exer_angina.305 exer_angina.306 exer_angina.307\n",
       " 0:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.308 exer_angina.309 exer_angina.310 exer_angina.311\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.312 exer_angina.313 exer_angina.314 exer_angina.315\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.316 exer_angina.317 exer_angina.318 exer_angina.319\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.320 exer_angina.321 exer_angina.322 exer_angina.323\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.324 exer_angina.325 exer_angina.326 exer_angina.327\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.328 exer_angina.329 exer_angina.330 exer_angina.331\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.332 exer_angina.333 exer_angina.334 exer_angina.335\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.336 exer_angina.337 exer_angina.338 exer_angina.339\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.340 exer_angina.341 exer_angina.342 exer_angina.343\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.344 exer_angina.345 exer_angina.346 exer_angina.347\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.348 exer_angina.349 exer_angina.350 exer_angina.351\n",
       " 0:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.352 exer_angina.353 exer_angina.354 exer_angina.355\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.356 exer_angina.357 exer_angina.358 exer_angina.359\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.360 exer_angina.361 exer_angina.362 exer_angina.363\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.364 exer_angina.365 exer_angina.366 exer_angina.367\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.368 exer_angina.369 exer_angina.370 exer_angina.371\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.372 exer_angina.373 exer_angina.374 exer_angina.375\n",
       " 0:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.376 exer_angina.377 exer_angina.378 exer_angina.379\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.380 exer_angina.381 exer_angina.382 exer_angina.383\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.384 exer_angina.385 exer_angina.386 exer_angina.387\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.388 exer_angina.389 exer_angina.390 exer_angina.391\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.392 exer_angina.393 exer_angina.394 exer_angina.395\n",
       " 1:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.396 exer_angina.397 exer_angina.398 exer_angina.399\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.400 exer_angina.401 exer_angina.402 exer_angina.403\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.404 exer_angina.405 exer_angina.406 exer_angina.407\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.408 exer_angina.409 exer_angina.410 exer_angina.411\n",
       " 0:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.412 exer_angina.413 exer_angina.414 exer_angina.415\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.416 exer_angina.417 exer_angina.418 exer_angina.419\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.420 exer_angina.421 exer_angina.422 exer_angina.423\n",
       " Min.   :0       1:920           1:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.424 exer_angina.425 exer_angina.426 exer_angina.427\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.428 exer_angina.429 exer_angina.430 exer_angina.431\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.432 exer_angina.433 exer_angina.434 exer_angina.435\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.436 exer_angina.437 exer_angina.438 exer_angina.439\n",
       " 0:920           1:920           1:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.440 exer_angina.441 exer_angina.442 exer_angina.443\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.444 exer_angina.445 exer_angina.446 exer_angina.447\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.448 exer_angina.449 exer_angina.450 exer_angina.451\n",
       " 1:920           Min.   :0       0:920           0:920          \n",
       "                 1st Qu.:0                                      \n",
       "                 Median :0                                      \n",
       "                 Mean   :0                                      \n",
       "                 3rd Qu.:0                                      \n",
       "                 Max.   :0                                      \n",
       " exer_angina.452 exer_angina.453 exer_angina.454 exer_angina.455\n",
       " Min.   :0       1:920           1:920           Min.   :0      \n",
       " 1st Qu.:0                                       1st Qu.:0      \n",
       " Median :0                                       Median :0      \n",
       " Mean   :0                                       Mean   :0      \n",
       " 3rd Qu.:0                                       3rd Qu.:0      \n",
       " Max.   :0                                       Max.   :0      \n",
       " exer_angina.456 exer_angina.457 exer_angina.458 exer_angina.459\n",
       " Min.   :0       1:920           1:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.460 exer_angina.461 exer_angina.462 exer_angina.463\n",
       " 1:920           1:920           Min.   :0       1:920          \n",
       "                                 1st Qu.:0                      \n",
       "                                 Median :0                      \n",
       "                                 Mean   :0                      \n",
       "                                 3rd Qu.:0                      \n",
       "                                 Max.   :0                      \n",
       " exer_angina.464 exer_angina.465 exer_angina.466 exer_angina.467\n",
       " Min.   :0       1:920           1:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.468 exer_angina.469 exer_angina.470 exer_angina.471\n",
       " 0:920           0:920           Min.   :0       1:920          \n",
       "                                 1st Qu.:0                      \n",
       "                                 Median :0                      \n",
       "                                 Mean   :0                      \n",
       "                                 3rd Qu.:0                      \n",
       "                                 Max.   :0                      \n",
       " exer_angina.472 exer_angina.473 exer_angina.474 exer_angina.475\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.476 exer_angina.477 exer_angina.478 exer_angina.479\n",
       " 1:920           Min.   :0       1:920           0:920          \n",
       "                 1st Qu.:0                                      \n",
       "                 Median :0                                      \n",
       "                 Mean   :0                                      \n",
       "                 3rd Qu.:0                                      \n",
       "                 Max.   :0                                      \n",
       " exer_angina.480 exer_angina.481 exer_angina.482 exer_angina.483\n",
       " 0:920           1:920           1:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.484 exer_angina.485 exer_angina.486 exer_angina.487\n",
       " Min.   :0       1:920           Min.   :0       1:920          \n",
       " 1st Qu.:0                       1st Qu.:0                      \n",
       " Median :0                       Median :0                      \n",
       " Mean   :0                       Mean   :0                      \n",
       " 3rd Qu.:0                       3rd Qu.:0                      \n",
       " Max.   :0                       Max.   :0                      \n",
       " exer_angina.488 exer_angina.489 exer_angina.490 exer_angina.491\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.492 exer_angina.493 exer_angina.494 exer_angina.495\n",
       " 0:920           1:920           Min.   :0       Min.   :0      \n",
       "                                 1st Qu.:0       1st Qu.:0      \n",
       "                                 Median :0       Median :0      \n",
       "                                 Mean   :0       Mean   :0      \n",
       "                                 3rd Qu.:0       3rd Qu.:0      \n",
       "                                 Max.   :0       Max.   :0      \n",
       " exer_angina.496 exer_angina.497 exer_angina.498 exer_angina.499\n",
       " 0:920           1:920           Min.   :0       1:920          \n",
       "                                 1st Qu.:0                      \n",
       "                                 Median :0                      \n",
       "                                 Mean   :0                      \n",
       "                                 3rd Qu.:0                      \n",
       "                                 Max.   :0                      \n",
       " exer_angina.500 exer_angina.501 exer_angina.502 exer_angina.503\n",
       " 1:920           0:920           0:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.504 exer_angina.505 exer_angina.506 exer_angina.507\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.508 exer_angina.509 exer_angina.510 exer_angina.511\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.512 exer_angina.513 exer_angina.514 exer_angina.515\n",
       " 1:920           Min.   :0       1:920           Min.   :0      \n",
       "                 1st Qu.:0                       1st Qu.:0      \n",
       "                 Median :0                       Median :0      \n",
       "                 Mean   :0                       Mean   :0      \n",
       "                 3rd Qu.:0                       3rd Qu.:0      \n",
       "                 Max.   :0                       Max.   :0      \n",
       " exer_angina.516 exer_angina.517 exer_angina.518 exer_angina.519\n",
       " 1:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.520 exer_angina.521 exer_angina.522 exer_angina.523\n",
       " Min.   :0       1:920           Min.   :0       1:920          \n",
       " 1st Qu.:0                       1st Qu.:0                      \n",
       " Median :0                       Median :0                      \n",
       " Mean   :0                       Mean   :0                      \n",
       " 3rd Qu.:0                       3rd Qu.:0                      \n",
       " Max.   :0                       Max.   :0                      \n",
       " exer_angina.524 exer_angina.525 exer_angina.526 exer_angina.527\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.528 exer_angina.529 exer_angina.530 exer_angina.531\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.532 exer_angina.533 exer_angina.534 exer_angina.535\n",
       " 1:920           1:920           0:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.536 exer_angina.537 exer_angina.538 exer_angina.539\n",
       " Min.   :0       Min.   :0       Min.   :0       Min.   :0      \n",
       " 1st Qu.:0       1st Qu.:0       1st Qu.:0       1st Qu.:0      \n",
       " Median :0       Median :0       Median :0       Median :0      \n",
       " Mean   :0       Mean   :0       Mean   :0       Mean   :0      \n",
       " 3rd Qu.:0       3rd Qu.:0       3rd Qu.:0       3rd Qu.:0      \n",
       " Max.   :0       Max.   :0       Max.   :0       Max.   :0      \n",
       " exer_angina.540 exer_angina.541 exer_angina.542 exer_angina.543\n",
       " Min.   :0       Min.   :0       0:920           1:920          \n",
       " 1st Qu.:0       1st Qu.:0                                      \n",
       " Median :0       Median :0                                      \n",
       " Mean   :0       Mean   :0                                      \n",
       " 3rd Qu.:0       3rd Qu.:0                                      \n",
       " Max.   :0       Max.   :0                                      \n",
       " exer_angina.544 exer_angina.545 exer_angina.546 exer_angina.547\n",
       " 1:920           Min.   :0       Min.   :0       1:920          \n",
       "                 1st Qu.:0       1st Qu.:0                      \n",
       "                 Median :0       Median :0                      \n",
       "                 Mean   :0       Mean   :0                      \n",
       "                 3rd Qu.:0       3rd Qu.:0                      \n",
       "                 Max.   :0       Max.   :0                      \n",
       " exer_angina.548 exer_angina.549 exer_angina.550 exer_angina.551\n",
       " 1:920           0:920           Min.   :0       0:920          \n",
       "                                 1st Qu.:0                      \n",
       "                                 Median :0                      \n",
       "                                 Mean   :0                      \n",
       "                                 3rd Qu.:0                      \n",
       "                                 Max.   :0                      \n",
       " exer_angina.552 exer_angina.553 exer_angina.554 exer_angina.555\n",
       " 1:920           1:920           1:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.556 exer_angina.557 exer_angina.558 exer_angina.559\n",
       " 0:920           0:920           0:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.560 exer_angina.561 exer_angina.562 exer_angina.563\n",
       " 0:920           0:920           Min.   :0       Min.   :0      \n",
       "                                 1st Qu.:0       1st Qu.:0      \n",
       "                                 Median :0       Median :0      \n",
       "                                 Mean   :0       Mean   :0      \n",
       "                                 3rd Qu.:0       3rd Qu.:0      \n",
       "                                 Max.   :0       Max.   :0      \n",
       " exer_angina.564 exer_angina.565 exer_angina.566 exer_angina.567\n",
       " 0:920           1:920           1:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.568 exer_angina.569 exer_angina.570 exer_angina.571\n",
       " Min.   :0       1:920           Min.   :0       Min.   :0      \n",
       " 1st Qu.:0                       1st Qu.:0       1st Qu.:0      \n",
       " Median :0                       Median :0       Median :0      \n",
       " Mean   :0                       Mean   :0       Mean   :0      \n",
       " 3rd Qu.:0                       3rd Qu.:0       3rd Qu.:0      \n",
       " Max.   :0                       Max.   :0       Max.   :0      \n",
       " exer_angina.572 exer_angina.573 exer_angina.574 exer_angina.575\n",
       " 1:920           Min.   :0       1:920           Min.   :0      \n",
       "                 1st Qu.:0                       1st Qu.:0      \n",
       "                 Median :0                       Median :0      \n",
       "                 Mean   :0                       Mean   :0      \n",
       "                 3rd Qu.:0                       3rd Qu.:0      \n",
       "                 Max.   :0                       Max.   :0      \n",
       " exer_angina.576 exer_angina.577 exer_angina.578 exer_angina.579\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.580 exer_angina.581 exer_angina.582 exer_angina.583\n",
       " 1:920           Min.   :0       1:920           0:920          \n",
       "                 1st Qu.:0                                      \n",
       "                 Median :0                                      \n",
       "                 Mean   :0                                      \n",
       "                 3rd Qu.:0                                      \n",
       "                 Max.   :0                                      \n",
       " exer_angina.584 exer_angina.585 exer_angina.586 exer_angina.587\n",
       " Min.   :0       Min.   :0       1:920           Min.   :0      \n",
       " 1st Qu.:0       1st Qu.:0                       1st Qu.:0      \n",
       " Median :0       Median :0                       Median :0      \n",
       " Mean   :0       Mean   :0                       Mean   :0      \n",
       " 3rd Qu.:0       3rd Qu.:0                       3rd Qu.:0      \n",
       " Max.   :0       Max.   :0                       Max.   :0      \n",
       " exer_angina.588 exer_angina.589 exer_angina.590 exer_angina.591\n",
       " 1:920           Min.   :0       Min.   :0       1:920          \n",
       "                 1st Qu.:0       1st Qu.:0                      \n",
       "                 Median :0       Median :0                      \n",
       "                 Mean   :0       Mean   :0                      \n",
       "                 3rd Qu.:0       3rd Qu.:0                      \n",
       "                 Max.   :0       Max.   :0                      \n",
       " exer_angina.592 exer_angina.593 exer_angina.594 exer_angina.595\n",
       " 1:920           Min.   :0       Min.   :0       0:920          \n",
       "                 1st Qu.:0       1st Qu.:0                      \n",
       "                 Median :0       Median :0                      \n",
       "                 Mean   :0       Mean   :0                      \n",
       "                 3rd Qu.:0       3rd Qu.:0                      \n",
       "                 Max.   :0       Max.   :0                      \n",
       " exer_angina.596 exer_angina.597 exer_angina.598 exer_angina.599\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.600 exer_angina.601 exer_angina.602 exer_angina.603\n",
       " Min.   :0       0:920           1:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.604 exer_angina.605 exer_angina.606 exer_angina.607\n",
       " 1:920           1:920           0:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.608 exer_angina.609 exer_angina.610 exer_angina.611\n",
       " 1:920           0:920           1:920           Min.   :0      \n",
       "                                                 1st Qu.:0      \n",
       "                                                 Median :0      \n",
       "                                                 Mean   :0      \n",
       "                                                 3rd Qu.:0      \n",
       "                                                 Max.   :0      \n",
       " exer_angina.612 exer_angina.613 exer_angina.614 exer_angina.615\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.616 exer_angina.617 exer_angina.618 exer_angina.619\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.620 exer_angina.621 exer_angina.622 exer_angina.623\n",
       " 0:920           0:920           Min.   :0       0:920          \n",
       "                                 1st Qu.:0                      \n",
       "                                 Median :0                      \n",
       "                                 Mean   :0                      \n",
       "                                 3rd Qu.:0                      \n",
       "                                 Max.   :0                      \n",
       " exer_angina.624 exer_angina.625 exer_angina.626 exer_angina.627\n",
       " Min.   :0       1:920           0:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.628 exer_angina.629 exer_angina.630 exer_angina.631\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.632 exer_angina.633 exer_angina.634 exer_angina.635\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.636 exer_angina.637 exer_angina.638 exer_angina.639\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.640 exer_angina.641 exer_angina.642 exer_angina.643\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.644 exer_angina.645 exer_angina.646 exer_angina.647\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.648 exer_angina.649 exer_angina.650 exer_angina.651\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.652 exer_angina.653 exer_angina.654 exer_angina.655\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.656 exer_angina.657 exer_angina.658 exer_angina.659\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.660 exer_angina.661 exer_angina.662 exer_angina.663\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.664 exer_angina.665 exer_angina.666 exer_angina.667\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.668 exer_angina.669 exer_angina.670 exer_angina.671\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.672 exer_angina.673 exer_angina.674 exer_angina.675\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.676 exer_angina.677 exer_angina.678 exer_angina.679\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.680 exer_angina.681 exer_angina.682 exer_angina.683\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.684 exer_angina.685 exer_angina.686 exer_angina.687\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.688 exer_angina.689 exer_angina.690 exer_angina.691\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.692 exer_angina.693 exer_angina.694 exer_angina.695\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.696 exer_angina.697 exer_angina.698 exer_angina.699\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.700 exer_angina.701 exer_angina.702 exer_angina.703\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.704 exer_angina.705 exer_angina.706 exer_angina.707\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.708 exer_angina.709 exer_angina.710 exer_angina.711\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.712 exer_angina.713 exer_angina.714 exer_angina.715\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.716 exer_angina.717 exer_angina.718 exer_angina.719\n",
       " Min.   :0       0:920           0:920           0:920          \n",
       " 1st Qu.:0                                                      \n",
       " Median :0                                                      \n",
       " Mean   :0                                                      \n",
       " 3rd Qu.:0                                                      \n",
       " Max.   :0                                                      \n",
       " exer_angina.720 exer_angina.721 exer_angina.722 exer_angina.723\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.724 exer_angina.725 exer_angina.726 exer_angina.727\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.728 exer_angina.729 exer_angina.730 exer_angina.731\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.732 exer_angina.733 exer_angina.734 exer_angina.735\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.736 exer_angina.737 exer_angina.738 exer_angina.739\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.740 exer_angina.741 exer_angina.742 exer_angina.743\n",
       " 0:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.744 exer_angina.745 exer_angina.746 exer_angina.747\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.748 exer_angina.749 exer_angina.750 exer_angina.751\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.752 exer_angina.753 exer_angina.754 exer_angina.755\n",
       " 1:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.756 exer_angina.757 exer_angina.758 exer_angina.759\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.760 exer_angina.761 exer_angina.762 exer_angina.763\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.764 exer_angina.765 exer_angina.766 exer_angina.767\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.768 exer_angina.769 exer_angina.770 exer_angina.771\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.772 exer_angina.773 exer_angina.774 exer_angina.775\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.776 exer_angina.777 exer_angina.778 exer_angina.779\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.780 exer_angina.781 exer_angina.782 exer_angina.783\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.784 exer_angina.785 exer_angina.786 exer_angina.787\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.788 exer_angina.789 exer_angina.790 exer_angina.791\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.792 exer_angina.793 exer_angina.794 exer_angina.795\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.796 exer_angina.797 exer_angina.798 exer_angina.799\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.800 exer_angina.801 exer_angina.802 exer_angina.803\n",
       " 0:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.804 exer_angina.805 exer_angina.806 exer_angina.807\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.808 exer_angina.809 exer_angina.810 exer_angina.811\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.812 exer_angina.813 exer_angina.814 exer_angina.815\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.816 exer_angina.817 exer_angina.818 exer_angina.819\n",
       " 0:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.820 exer_angina.821 exer_angina.822 exer_angina.823\n",
       " 0:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.824 exer_angina.825 exer_angina.826 exer_angina.827\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.828 exer_angina.829 exer_angina.830 exer_angina.831\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.832 exer_angina.833 exer_angina.834 exer_angina.835\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.836 exer_angina.837 exer_angina.838 exer_angina.839\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.840 exer_angina.841 exer_angina.842 exer_angina.843\n",
       " 1:920           1:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.844 exer_angina.845 exer_angina.846 exer_angina.847\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.848 exer_angina.849 exer_angina.850 exer_angina.851\n",
       " 0:920           0:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.852 exer_angina.853 exer_angina.854 exer_angina.855\n",
       " 1:920           0:920           0:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.856 exer_angina.857 exer_angina.858 exer_angina.859\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.860 exer_angina.861 exer_angina.862 exer_angina.863\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.864 exer_angina.865 exer_angina.866 exer_angina.867\n",
       " 0:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.868 exer_angina.869 exer_angina.870 exer_angina.871\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.872 exer_angina.873 exer_angina.874 exer_angina.875\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.876 exer_angina.877 exer_angina.878 exer_angina.879\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.880 exer_angina.881 exer_angina.882 exer_angina.883\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.884 exer_angina.885 exer_angina.886 exer_angina.887\n",
       " 1:920           1:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.888 exer_angina.889 exer_angina.890 exer_angina.891\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.892 exer_angina.893 exer_angina.894 exer_angina.895\n",
       " 1:920           0:920           0:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.896 exer_angina.897 exer_angina.898 exer_angina.899\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.900 exer_angina.901 exer_angina.902 exer_angina.903\n",
       " 1:920           0:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.904 exer_angina.905 exer_angina.906 exer_angina.907\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.908 exer_angina.909 exer_angina.910 exer_angina.911\n",
       " 1:920           1:920           1:920           0:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.912 exer_angina.913 exer_angina.914 exer_angina.915\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " exer_angina.916 exer_angina.917 exer_angina.918 exer_angina.919\n",
       " 1:920           1:920           1:920           1:920          \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       "                                                                \n",
       " ST_depression      Peak_ST_seg    major_vessels         thal     \n",
       " Min.   :-2.6000   Min.   :1.000   Min.   :0.0000   Min.   :3.00  \n",
       " 1st Qu.: 0.0000   1st Qu.:2.000   1st Qu.:0.0000   1st Qu.:6.00  \n",
       " Median : 0.8000   Median :2.000   Median :0.0000   Median :6.00  \n",
       " Mean   : 0.8832   Mean   :1.848   Mean   :0.2272   Mean   :5.57  \n",
       " 3rd Qu.: 1.5000   3rd Qu.:2.000   3rd Qu.:0.0000   3rd Qu.:6.00  \n",
       " Max.   : 6.2000   Max.   :3.000   Max.   :3.0000   Max.   :7.00  \n",
       " has_heart_disease\n",
       " Min.   :0.0000   \n",
       " 1st Qu.:0.0000   \n",
       " Median :1.0000   \n",
       " Mean   :0.9957   \n",
       " 3rd Qu.:2.0000   \n",
       " Max.   :4.0000   \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%R -i df_imputed \n",
    "print(summary(df_imputed))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So we are able to call some R and get console output, now let's make some changes to the data.fram in R and print the result back in python."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n",
      "after manipulation in R: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print ('original:', df_imputed.age.head())\n",
    "\n",
    "# give df_imputed, then multiply it by to in R\n",
    "# the %R command tells iPython its just one line of R code\n",
    "%R -i df_imputed df_imputed$age <- df_imputed$age*2\n",
    "\n",
    "# now we are back in python, did it change?\n",
    "print ('after manipulation in R:', df_imputed.age.head())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Well, it looks like the data was not synchronized... So instead let's setup an output variable for the DataFrame that we send into R. `-i df_imputed` means that we are sending in the DataFrame as an R data.frame. `-o df_imputed` means we are also getting the same variable and copying it back to the python workspace."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original: 0    63\n",
      "1    67\n",
      "2    67\n",
      "3    37\n",
      "4    41\n",
      "Name: age, dtype: int64\n",
      "after manipulation in R: 0    126.0\n",
      "1    134.0\n",
      "2    134.0\n",
      "3     74.0\n",
      "4     82.0\n",
      "Name: age, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "print ('original:', df_imputed.age.head() )\n",
    "\n",
    "# This is the same code as before, but now with an output variable\n",
    "%R -i df_imputed -o df_imputed  df_imputed$age <- df_imputed$age*2\n",
    "# you can place the above on any line to make sure that the data stays\n",
    "# synchronized between pandas and python\n",
    "print ('after manipulation in R:', df_imputed.age.head())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Awesome. So now we can send DataFrames into R, manipulate them, and get them back into the python workspace. Is this memory hogging? Yes. Is it really useful for when you want to connect and work with different parts of R? You betcha."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 920 entries, 0 to 919\n",
      "Columns: 1852 entries, age to has_heart_disease\n",
      "dtypes: float64(154), int32(2), object(1696)\n",
      "memory usage: 13.0+ MB\n"
     ]
    }
   ],
   "source": [
    "# We can also just go and get new variables from R and \n",
    "# have them spit them back out for us\n",
    "# here I am sending in df_imputed and getting back a data frame\n",
    "# created in R\n",
    "%R -i df_imputed -o df_from_R df_from_R <- df_imputed\n",
    "\n",
    "# notice that the only differebce is that the integers are 32 bits\n",
    "df_from_R.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's it. Use this as a reference sheet for Pandas, some basic imputation, and calling R code. Thanks!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:MLEnv]",
   "language": "python",
   "name": "conda-env-MLEnv-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
